<?php
namespace Home\Controller;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {
    public function index(){
        $map['position']=array('eq','snatch_banner');
        $index_banner=M('ad')->where($map)->order("sort asc")->select();
        if (!empty($index_banner)) {
        	$banner_info['first'] = $index_banner[0];
        	$banner_info['last'] = $index_banner[count($index_banner) - 1];
        	$banner_info['list'] = $index_banner;
        }
        $snatch_list = M("snatch")->where(array('status'=>1))->order("add_time desc")->limit(4)->select();
        $lottery_list = M("snatch")->where(array('status'=>2,'lottery_uid'=>['gt',0]))->order("add_time desc")->limit(4)->select();
        $this->assign('banner_info',$banner_info);
        $this->assign('snatch_list',$snatch_list);
        $this->assign('lottery_list',$lottery_list);
        $this->display();
    }
}